$(function () {
    $('.am-header-title').text('好店');
    var url = "/catalog/catalogListByParent?parentCode=" + "haodian";
    $.get(url, function (result) {
        var datas = result.catalogList;
        var liHtml = '';

        for (var i = 0; i < datas.length; i++) {

            if (i == 0) {
                //liHtml+='<div class="hd-list-box1"><div class="hd-list'+ (i+1) +'"><div class="am-gallery-item"><a href="./store-list.jsp?catId='+ datas[i].id +'" class=""><img src="../../img/index3-'+ (i+1) +'.jpg" alt="datas[i].name"/></a></div></div>'
                liHtml += '<div class="hd-list-box1">'
                    + '<div class="hd-list-box1-l">'
                    + '<a href="./store-list.jsp?catId=' + datas[i].id + '"><img src="../../img/xijianchui.png" alt=""></a>'
                    + '</div>'
                    + '<div class="hd-list-box1-r">'
                    + '<div class="t">'
            }
            if (i == 1) {
                liHtml += '<a href="./store-list.jsp?catId=' + datas[i].id + '"><img src="../../img/baojiananmo.png" alt=""></a>'
            }
            if (i == 2) {
                //liHtml+='<div class="hd-list'+ (i+1) +'"><div class="am-gallery-item"><a href="./store-list.jsp?catId='+ datas[i].id +'" class=""><img src="../../img/index3-'+ (i+1) +'.jpg" alt="datas[i].name"/></a></div></div>'
                liHtml += '</div>'
                    + '<div class="b">'
                    + '<a href="./store-list.jsp?catId=' + datas[i].id + '"><img src="../../img/meirongmeiti.png" alt=""></a>'
                    + '</div>'
                    + '</div>'
                    + '</div>';
            }
            if (i == 3) {
                //liHtml+='<div class="hd-list'+ (i+1) +'"><div class="am-gallery-item"><a href="./store-list.jsp?catId='+ datas[i].id +'" class=""><img src="../../img/index3-'+ (i+1) +'.jpg" alt="datas[i].name"/></a></div></div>'
                liHtml += '<div class="hd-list-box2">'
                    + '<div class="hd-list-box2-l">'
                    + '<a href="./store-list.jsp?catId=' + datas[i].id + '"><img src="../../img/meijia.png" alt=""></a>'
                    + '</div>'
            }
            if (i == 4) {
                //liHtml+='<div class="hd-list'+ (i+1) +'"><div class="am-gallery-item"><a href="./store-list.jsp?catId='+ datas[i].id +'" class=""><img src="../../img/index3-'+ (i+1) +'.jpg" alt="datas[i].name"/></a></div></div>'
                liHtml += '<div class="hd-list-box2-r">'
                    + '<a href="./store-list.jsp?catId=' + datas[i].id + '"><img src="../../img/tangranhu.png" alt=""></a>'
                    + '</div>'
                    + '</div>';
            }


            //<div class="hd-list-box1">
            //<div class="hd-list-box1-l">
            //<img src="../../img/xijianchui.png" alt="">
            //</div>
            //<div class="hd-list-box1-r">
            //<div class="t">
            //<img src="../../img/koubeihaodian.png" alt="">
            //</div>
            //<div class="b">
            //<img src="../../img/meirongmeiti.png" alt="">
            //</div>
            //</div>
            //</div>
            //<div class="hd-list-box2">
            //<div class="hd-list-box2-l">
            //<img src="../../img/tangranhu.png" alt="">
            //</div>
            //<div class="hd-list-box2-r">
            //<img src="../../img/meijia.png" alt="">
            //</div>
            //</div>


            //switch (i){
            //    case 0:
            //        liHtml.push('<div class="hd-list-box1"><div class="hd-list'+ (i+1) +'"><div class="am-gallery-item"><a href="./store-list.jsp?catId='+ datas[i].id +'" class=""><img src="../../img/index3-'+ (i+1) +'.jpg" alt="datas[i].name"/></a></div></div>');
            //        break;
            //    case 1:
            //        liHtml.push('<div class="hd-list'+ (i+1) +'"><div class="am-gallery-item"><a href="./store-list.jsp?catId='+ datas[i].id +'" class=""><img src="../../img/index3-'+ (i+1) +'.jpg" alt="datas[i].name"/></a></div></div>');
            //        break;
            //    case 2:
            //        liHtml.push('<div class="hd-list'+ (i+1) +'"><div class="am-gallery-item"><a href="./store-list.jsp?catId='+ datas[i].id +'" class=""><img src="../../img/index3-'+ (i+1) +'.jpg" alt="datas[i].name"/></a></div></div></div>');
            //        break;
            //    case 3:
            //        liHtml.push('<div class="hd-list'+ (i+1) +'"><div class="am-gallery-item"><a href="./store-list.jsp?catId='+ datas[i].id +'" class=""><img src="../../img/index3-'+ (i+1) +'.jpg" alt="datas[i].name"/></a></div></div>');
            //
            //        break;
            //    case 4:
            //        liHtml.push('<div class="hd-list'+ (i+1) +'"><div class="am-gallery-item"><a href="./store-list.jsp?catId='+ datas[i].id +'" class=""><img src="../../img/index3-'+ (i+1) +'.jpg" alt="datas[i].name"/></a></div></div>');
            //        break;
            //    default:
            //        break;
            //
            //}
        }
        $("#haodian").append(liHtml);


        //var handleHelper = Handlebars.registerHelper("addOne", function (index) {
        //    return index + 1;
        //});
        //
        //Handlebars.registerHelper('ex', function(conditional, options) {
        //    console.log(conditional)
        //    console.log(options)
        //    if(conditional) {
        //        return options.fn(this);
        //    }
        //});
        //var source = $('#haodian-template').html();
        //var template = Handlebars.compile(source);
        //var html = template(result);
        //$("#haodian").append(html);
    });


    var url1 = "/h5GoodShop/bannerList";
    $.post(url1, function (result) {

        var source = $('#banner-template').html();
        var template = Handlebars.compile(source);
        var html = template(result);
        $(".am-slides").append(html);
        $('.am-slider').flexslider();
    });

});
